package com.opennews.openplatform.myspringbootcore.util

import com.fasterxml.jackson.core.JsonParser
import com.fasterxml.jackson.databind.DeserializationContext
import com.fasterxml.jackson.databind.JsonDeserializer
import java.time.LocalDateTime

class UTCToLocalDateTimeDeserializer : JsonDeserializer<LocalDateTime>() {
    override fun deserialize(
        p: JsonParser?,
        ctxt: DeserializationContext?,
    ): LocalDateTime? {
        return if (p != null) DateHelper.convertUTCStringToLocalDateTime(p.text.trim()) else null
    }
}